package com.ljf.finance.domain.service;

import com.ljf.common.domain.service.BasisDomainService;
import com.ljf.common.exception.ServiceException;
import com.ljf.finance.domain.repository.FinanceDatVirtualAccountRepository;
import com.ljf.finance.dto.command.FinanceDatVirtualAccountCommand;
import com.ljf.finance.dto.query.FinanceDatVirtualAccountQuery;
import com.ljf.finance.enums.FinanceDatVirtualAccountCommonUsedEnum;
import com.ljf.finance.model.FinanceDatVirtualAccount;
import com.ljf.finance.vo.FinanceDatVirtualAccountVO;
import org.springframework.stereotype.Component;

import java.math.BigDecimal;
import java.util.List;

/**
 * 虚拟账户定义  领域服务
 *
 * @author LJF
 * @since 2024-02-09
 */
@Component
public class FinanceDatVirtualAccountDomainService extends BasisDomainService<FinanceDatVirtualAccountRepository, FinanceDatVirtualAccountQuery, FinanceDatVirtualAccountVO, FinanceDatVirtualAccount, FinanceDatVirtualAccountCommand> {

    @Override
    public FinanceDatVirtualAccount add(FinanceDatVirtualAccountCommand command) throws ServiceException {
        command.setAmount(BigDecimal.ZERO);
        return super.add(command);
    }

    /**
     * 常用账户查询
     *
     * @param query
     * @return
     * @throws ServiceException
     */
    public List<FinanceDatVirtualAccountVO> queryCommonUsed(FinanceDatVirtualAccountQuery query) throws ServiceException {
        query.setCommonUsed(FinanceDatVirtualAccountCommonUsedEnum.TURE.getCode());
        return super.queryList(query);
    }

}
